package com.hh.usersystem.service.impl;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import com.hh.system.service.impl.BaseService;
import com.hh.usersystem.bean.usersystem.HhXtYhCdZmtb;

@Service
public class ZmtbService extends BaseService<HhXtYhCdZmtb> {
	public void updateOrder(String id1, String order1, String id2, String order2) {
		HhXtYhCdZmtb entity1 = dao.findEntity(HhXtYhCdZmtb.class,
				Restrictions.eq("cdId", id1));
		String order1_ = entity1.getOrder();
		HhXtYhCdZmtb entity2 = dao.findEntity(HhXtYhCdZmtb.class,
				Restrictions.eq("cdId", id2));
		String order2_ = entity2.getOrder();
		dao.updateEntity("update " + HhXtYhCdZmtb.class.getName()
				+ " o set o.order=? where o.cdId=?", new Object[] { order1_,
				id2 });
		dao.updateEntity("update " + HhXtYhCdZmtb.class.getName()
				+ " o set o.order=? where o.cdId=?", new Object[] { order2_,
				id1 });
	}
}